package dao

import (
	"context"
	"server/repository/model"
)

type UserDao struct {
	Repo[model.UserModel]
}

func (o *UserDao) IsNameExist(ctx context.Context, name string) bool {
	exist, _ := o.Repo.IsExist(ctx, "name = ?", name)
	return exist
}

func (o *UserDao) FindByName(ctx context.Context, name string) (*model.UserModel, error) {
	return o.FindByWhere(ctx, "name = ?", name)
}

func (o *UserDao) FindByToken(ctx context.Context, token string) (*model.UserModel, error) {
	return o.FindByWhere(ctx, "token = ?", token)
}

func (o *UserDao) FindByUuid(ctx context.Context, uuid string) (*model.UserModel, error) {
	return o.FindByWhere(ctx, "uuid = ?", uuid)
}
